let originData = require("./result.json");
let { handelGetEveyNode, handleNodeNogoging } = require("./util/index.js");
let { handleGetItemPrev } = require("./util/getItemPrev.js");
let { handleDataToOne } = require("./util/oneFlat.js");
let flattenData = handleDataToOne(originData);
/*
 *baseData 流程平台生成的结果
 *flatData 根据baseData直接生成的平级数据[{},{}]
 */
const getData = (baseData, flatData) => {
  let originArrs = handleGetItemPrev(flatData, baseData);
  handelGetEveyNode(baseData, originArrs);
  // 处理不带outging的子节点
  let childNodesNogoingArrs = handleNodeNogoging(baseData);
  handelGetEveyNode(baseData, childNodesNogoingArrs);
  return baseData || {};
};

// 结果
let result = getData(originData, flattenData);
// console.log(JSON.stringify(result));
console.log(JSON.stringify(handleDataToOne(result))); //平级的数据
